<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<h2>把 JavaScript 对象转换为 JSON 字符串，然后发送到服务器。</h2>
<p id="demo"></p>

<script>
    // var myObj = { "name":"Bill Gates",  "age":62, "city":"Seattle" };
    // var myJSON = JSON.stringify(myObj);
    // console.log(myJSON)
    //
    // var myJSON = '{ "name":"Bill Gates",  "age":62, "city":"Seattle" }';
    // var myObj =  JSON.parse(myJSON);
    // document.getElementById("demo").innerHTML = myObj.name;

    //存储数据：
    myObj = { name:"Bill Gates",  age:62, city:"Seattle" };
    myJSON =  JSON.stringify(myObj);
    localStorage.setItem("testJSON", myJSON);

    //接收数据：
    text = localStorage.getItem("testJSON");
    obj =  JSON.parse(text);
    document.getElementById("demo").innerHTML = obj.name;

    let str = '{ "name":"Bill Gates", "age":62, "city":"Seattle"}'
    console.log(str)
    var obj = JSON.parse('{ "name":"Bill Gates", "age":62, "city":"Seattle"}');
    console.log(obj)

    $(document).ready(function () {

    })
</script>

</body>
</html>